/**
 * 常量配置文件
 * 统一管理前端应用中的常量，提高可维护性
 */

// API相关常量
export const API_CONFIG = {
  // 基础路径
  BASE_URL: '/api',

  // 请求超时时间 (毫秒)
  TIMEOUT: 10000,

  // 分页配置
  PAGINATION: {
    DEFAULT_PAGE_SIZE: 10,
    PAGE_SIZE_OPTIONS: [10, 20, 50, 100],
    SHOW_SIZE_CHANGER: true,
    SHOW_QUICK_JUMPER: true
  }
}

// 路由名称常量
export const ROUTE_NAMES = {
  HOME: 'Home',
  BLOG_DETAIL: 'BlogDetail',
  CATEGORY: 'Category',
  TAG: 'Tag',
  ALL_ARTICLES: 'AllArticles',
  LATEST_ARTICLES: 'LatestArticles',
  ABOUT: 'About'
}

// 路由路径常量
export const ROUTE_PATHS = {
  HOME: '/',
  BLOG_DETAIL: '/blog/:id',
  CATEGORY: '/category/:id',
  TAG: '/tag/:id',
  ALL_ARTICLES: '/all-articles',
  LATEST_ARTICLES: '/latest-articles',
  ABOUT: '/about'
}

// 本地存储键名
export const STORAGE_KEYS = {
  TOKEN: 'token',
  USER_INFO: 'userInfo',
  THEME: 'theme',
  LANGUAGE: 'language',
  VISITED_ARTICLES: 'visitedArticles'
}

// HTTP状态码
export const HTTP_STATUS = {
  SUCCESS: 200,
  CREATED: 201,
  NO_CONTENT: 204,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_SERVER_ERROR: 500,
  BAD_GATEWAY: 502,
  SERVICE_UNAVAILABLE: 503,
  GATEWAY_TIMEOUT: 504
}

// 业务状态码
export const BUSINESS_CODE = {
  SUCCESS: 200,
  SUCCESS_ALT: 0,
  ERROR: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  VALIDATION_ERROR: 422,
  SERVER_ERROR: 500
}

// 消息类型
export const MESSAGE_TYPE = {
  SUCCESS: 'success',
  INFO: 'info',
  WARNING: 'warning',
  ERROR: 'error'
}

// 文章状态
export const ARTICLE_STATUS = {
  DRAFT: 'draft',
  PUBLISHED: 'published',
  ARCHIVED: 'archived'
}

// 分类和标签颜色配置
export const TAG_COLORS = [
  'magenta', 'red', 'volcano', 'orange', 'gold',
  'lime', 'green', 'cyan', 'blue', 'geekblue', 'purple'
]

export const CATEGORY_COLORS = [
  'blue', 'green', 'orange', 'red', 'purple',
  'cyan', 'magenta', 'yellow', 'lime', 'geekblue'
]

// 日期格式
export const DATE_FORMAT = {
  DEFAULT: 'YYYY-MM-DD',
  WITH_TIME: 'YYYY-MM-DD HH:mm:ss',
  CHINESE: 'YYYY年MM月DD日',
  CHINESE_WITH_TIME: 'YYYY年MM月DD日 HH:mm:ss',
  MONTH_DAY: 'MM-DD',
  YEAR_MONTH: 'YYYY-MM',
  TIME_ONLY: 'HH:mm:ss'
}

// 加载状态
export const LOADING_STATE = {
  IDLE: 'idle',
  LOADING: 'loading',
  SUCCESS: 'success',
  ERROR: 'error'
}

// 组件尺寸
export const COMPONENT_SIZE = {
  SMALL: 'small',
  MEDIUM: 'medium',
  LARGE: 'large'
}

// 响应式断点
export const BREAKPOINTS = {
  XS: 'xs', // < 576px
  SM: 'sm', // >= 576px
  MD: 'md', // >= 768px
  LG: 'lg', // >= 992px
  XL: 'xl', // >= 1200px
  XXL: 'xxl' // >= 1600px
}

// 动画持续时间
export const ANIMATION_DURATION = {
  FAST: 200,
  NORMAL: 300,
  SLOW: 500
}

// 文件上传配置
export const UPLOAD_CONFIG = {
  MAX_SIZE: 5 * 1024 * 1024, // 5MB
  ACCEPTED_TYPES: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp'],
  ACCEPTED_EXTENSIONS: ['.jpg', '.jpeg', '.png', '.gif', '.webp']
}

// 正则表达式
export const REGEX_PATTERNS = {
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  PHONE: /^1[3-9]\d{9}$/,
  URL: /^https?:\/\/.+/,
  CHINESE: /[\u4e00-\u9fa5]/,
  PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{8,}$/
}

// 错误消息
export const ERROR_MESSAGES = {
  NETWORK_ERROR: '网络连接失败，请检查网络设置',
  REQUEST_TIMEOUT: '请求超时，请稍后重试',
  SERVER_ERROR: '服务器错误，请稍后重试',
  UNAUTHORIZED: '登录已过期，请重新登录',
  FORBIDDEN: '没有权限访问此资源',
  NOT_FOUND: '请求的资源不存在',
  VALIDATION_ERROR: '数据验证失败',
  UNKNOWN_ERROR: '未知错误，请联系管理员'
}

// 成功消息
export const SUCCESS_MESSAGES = {
  SAVE_SUCCESS: '保存成功',
  UPDATE_SUCCESS: '更新成功',
  DELETE_SUCCESS: '删除成功',
  UPLOAD_SUCCESS: '上传成功',
  SUBMIT_SUCCESS: '提交成功'
}

// 默认配置
export const DEFAULT_CONFIG = {
  ARTICLES_PER_PAGE: 10,
  SEARCH_DEBOUNCE_TIME: 300,
  AUTO_SAVE_INTERVAL: 30000, // 30秒
  CACHE_EXPIRE_TIME: 5 * 60 * 1000, // 5分钟
  MAX_SEARCH_HISTORY: 10
}

// 主题配置
export const THEME_CONFIG = {
  LIGHT: 'light',
  DARK: 'dark',
  AUTO: 'auto'
}

// 语言配置
export const LANGUAGE_CONFIG = {
  ZH_CN: 'zh-CN',
  EN_US: 'en-US'
}

// 导出所有常量的默认对象
export default {
  API_CONFIG,
  ROUTE_NAMES,
  ROUTE_PATHS,
  STORAGE_KEYS,
  HTTP_STATUS,
  BUSINESS_CODE,
  MESSAGE_TYPE,
  ARTICLE_STATUS,
  TAG_COLORS,
  CATEGORY_COLORS,
  DATE_FORMAT,
  LOADING_STATE,
  COMPONENT_SIZE,
  BREAKPOINTS,
  ANIMATION_DURATION,
  UPLOAD_CONFIG,
  REGEX_PATTERNS,
  ERROR_MESSAGES,
  SUCCESS_MESSAGES,
  DEFAULT_CONFIG,
  THEME_CONFIG,
  LANGUAGE_CONFIG
}